<template>
  <el-dialog
    v-el-drag-dialog
    title="新增充装单"
    :visible.sync="visible"
    width="1000px"
    @closed="closed"
  >
    <el-steps :align-center="true" :active="stepActive" finish-status="success">
      <el-step title="选择提瓶充装人员" />
      <el-step title="填写提瓶充装信息" />
    </el-steps>
    <div v-if="stepActive===1">
      <div class="userType">
        <span>提瓶充装人员：</span>
        <el-radio-group v-model="form.withdrawType" @change="withdrawTypeChange">
          <el-radio :label="1">配送员</el-radio>
          <el-radio :label="2">用户</el-radio>
        </el-radio-group>
      </div>
      <el-form v-if="form.withdrawType===1" ref="form" :model="form" label-width="118px">
        <el-form-item label="选择责任机构：">
          <el-tree-select
            v-model="form.orgSNNo"
            clearable
            class="tree-select"
            :popover-width="360"
            :select-params="{
              clearable: true,
              placeholder: '请选择',
              loading: $loadingPlugin.getTreeData,
            }"
            :tree-params="{
              'expand-on-click-node': false,
              'highlight-current': true,
              'filterable': true,
              props: {
                value: 'orgSNNo',
                label: 'orgName',
                disabled: 'disabled',
              },
              data: treeData,
            }"
            @node-click="selectTreeChange"
            @select-clear="closeTree"
          />
        </el-form-item>
        <el-form-item label="选择配送人员：">
          <el-select v-model="form.withdrawId" clearable filterable class="userList" placeholder="请选择">
            <el-option
              v-for="(item,index) in ownerList"
              :key="index"
              :label="item.userName"
              :value="item.userId"
            />
          </el-select>
        </el-form-item>
        <!-- 隐藏单据标签（佳） -->
        <!-- <el-form-item label="单据标签:">
          <el-select v-model="form.fillingLabel" filterable clearable class="userList" placeholder="请选择">
            <el-option
              v-for="item in fillingLabelList"
              :key="item.value"
              :label="item.keyName"
              :value="item.keyVal"
            />
          </el-select>
        </el-form-item> -->
      </el-form>
      <div v-else>
        <!-- 隐藏单据标签（佳） -->
        <!-- <el-form :inline="true" :model="customerQuery" class="customerForm">
          <el-form-item label="单据标签:">
            <el-select v-model="customerQuery.fillingLabel" filterable clearable placeholder="请选择">
              <el-option
                v-for="item in fillingLabelList"
                :key="item.value"
                :label="item.keyName"
                :value="item.keyVal"
              />
            </el-select>
          </el-form-item>
        </el-form> -->
        <el-form :inline="true" :model="customerForm" class="customerForm">
          <el-form-item label="人员姓名:">
            <el-input v-model.trim="customerForm.csmName" placeholder="请输入" clearable @keyup.enter.native="onKeyupType" />
          </el-form-item>
          <el-form-item label="人员编号:">
            <el-input v-model.trim="customerForm.csmCode" placeholder="请输入" clearable @keyup.enter.native="onKeyupType" />
          </el-form-item>
          <el-form-item label="联系电话:">
            <el-input v-model.trim="customerForm.csmRgPhone" placeholder="请输入" clearable @keyup.enter.native="onKeyupType" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" size="mini" :loading="$loadingPlugin.getCustormerInfo" @click="onSubmit">查询</el-button>
          </el-form-item>
        </el-form>

        <lb-table
          ref="userLbTable"
          border
          :height="358"
          highlight-current-row
          element-loading-text="加载中"
          :column="userTableData.column"
          :data="userTableData.data"
          pagination
          :total="userTableData.total"
          :immediate-fetch="false"
          @fetch="getCustormerInfo"
          @row-click="rowSelect"
        />
      </div>

      <!-- <div class="btn-b">
        <el-button type="default" @click="usercancel">取消</el-button>
        <el-button type="primary" @click="userNext">下一步</el-button>
      </div> -->
    </div>
    <div v-if="stepActive===2">
      <div class="item-title">提瓶充装人员信息：</div>
      <div v-if="form.withdrawType===1">
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="grid-content">
              <span>提瓶人：</span><span>{{ fillingInfo.userInfo.userName }}</span><span style="color: red;">(配送员)</span>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content">
              <span>责任机构：</span><span>{{ fillingInfo.orgInfo.orgName }}</span>
            </div>
          </el-col>
          <!-- <el-col :span="8">
            <div class="grid-content">
              <span>单据标签：</span><span>{{ fillingInfo.fillingLabelName }}</span>
            </div>
          </el-col> -->
        </el-row>
      </div>
      <div v-else>
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="grid-content">
              <span>提瓶人：</span><span>{{ fillingInfo.userInfo.csmName }}</span><span style="color: red;">(用户)</span>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content">
              <span>用户类型：</span><span>{{ csmTypeMap[fillingInfo.userInfo.csmType] }}</span>
            </div>
          </el-col>
          <!-- <el-col :span="8">
            <div class="grid-content">
              <span>单据标签：</span><span>{{ fillingInfo.fillingLabelName }}</span>
            </div>
          </el-col> -->
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="grid-content">
              <span>用户编号：</span><span>{{ fillingInfo.userInfo.csmCode }}</span>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content">
              <span>联系电话：</span><span>{{ fillingInfo.userInfo.csmRgPhone }}</span>
            </div>
          </el-col>
        </el-row>
      </div>
      <div class="add">
        <span class="item-title">充装明细信息：</span>
        <!-- <el-button type="primary" size="mini" @click="add">添加</el-button> -->
      </div>
      <el-table
        :data="fillingData"
        :summary-method="getSummaries"
        show-summary
        class="fillingList"
        style="width: 100%;"
      >
        <el-table-column
          prop="goodsId"
          label="商品信息"
        >
          <template slot-scope="scope">
            <!-- <el-select v-if="scope.row.isEdit" v-model="scope.row.goodsId" placeholder="请选择" @change="goodsIdChange(scope.row,scope.$index)">
              <el-option
                v-for="(item,index) in goodList"
                :key="index"
                :label="item.goodsName"
                :value="item.goodsId"
              />
            </el-select>
            <span v-else>{{ scope.row.goodsName }}</span> -->
            <span>{{ scope.row.goodsName }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="specAlias"
          label="规格"
          width="100"
        />
        <el-table-column
          prop="weight"
          label="重量(kg)"
          width="100"
        >
          <!-- <template slot-scope="scope">
            <el-input-number v-if="scope.row.isEdit" v-model="scope.row.weight" :min="1" :max="999" :controls="false" @blur="countPriceChange(scope.row,scope.$index)" />
            <span v-else>{{ scope.row.weight?scope.row.weight.toFixed(2):'0.00' }}</span>
          </template> -->
        </el-table-column>
        <el-table-column
          prop="gPrice"
          label="商品单价(元)"
          width="100"
        >
          <template slot-scope="scope">
            <el-input-number v-if="scope.row.isEdit" v-model="scope.row.gPrice" :precision="2" :min="0.00" :max="999" :controls="false" @blur="countPriceChange(scope.row,scope.$index)" />
            <span v-else>{{ scope.row.gPrice?scope.row.gPrice.toFixed(2):'0.00' }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="goodsCount"
          label="数量(瓶)"
          width="100"
        >
          <template slot-scope="scope">
            <el-input-number v-if="scope.row.isEdit" v-model="scope.row.goodsCount" :min="0" :max="999" :controls="false" @blur="countPriceChange(scope.row,scope.$index)" />
            <span v-else>{{ scope.row.goodsCount }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="gPrefPrice"
          label="优惠金额(元)"
          width="100"
        >
          <template slot-scope="scope">
            <el-input-number v-if="scope.row.isEdit" v-model="scope.row.gPrefPrice" :precision="2" :controls="false" @blur="countPriceChange(scope.row,scope.$index)" />
            <span v-else>{{ scope.row.gPrefPrice?scope.row.gPrefPrice:'0.00' }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="totalPrice"
          label="总金额(元)"
          width="100"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.totalPrice?scope.row.totalPrice:'0.00' }}</span>
          </template>
        </el-table-column>
        <!-- <el-table-column
          label="操作"
        >
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="editClick(scope.row,scope.$index,)">{{ scope.row.isEdit?'保存':'编辑' }}</el-button>
            <el-button class="del" type="text" size="small" @click="delClick(scope.row,scope.$index,)">删除</el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <!-- <div class="btn-b">
        <el-button type="default" @click="cancel">取消</el-button>
        <el-button type="primary" :loading="$loadingPlugin.save" @click="save">保存</el-button>
        <el-button type="primary" :loading="$loadingPlugin.saveAndPrint" @click="saveAndPrint">保存并打印</el-button>
      </div> -->
    </div>
    <span slot="footer" class="btn-b">
      <div class="tips">（优惠金额支持输入负数，正数表示下调，负数表示上调）</div>
      <div v-if="stepActive===1">
        <el-button type="default" @click="usercancel">取消</el-button>
        <el-button type="primary" @click="userNext">下一步</el-button>
      </div>
      <div v-if="stepActive===2">
        <el-button type="default" @click="cancel">取消</el-button>
        <el-button type="primary" :loading="$loadingPlugin.save" @click="save">保存</el-button>
        <el-button type="primary" :loading="$loadingPlugin.saveAndPrint" @click="saveAndPrint">保存并打印</el-button>
      </div>
    </span>
  </el-dialog>
</template>

<script>
  import getTreeData from '@/utils/jsonTree'
  import { mapGetters } from 'vuex'
  import { fillingCsmList, fillingSave, getfillingDetail, csDeliverUserList, recycleEditWinNew } from '@/api'
  import { csmTypeMap } from '@/utils/map'
  import { formatColumnMap, parseTime } from '@/utils'
  import { getSummaries } from '../js/summary'
  export default {
    name: 'fillingDetail',
    props: {
      fillingLabelList: {
        type: Array,
        default: () => []
      }
    },
    data() {
      return {
        csmTypeMap,
        visible: false,
        stepActive: 1,
        userList: [],
        treeData: [],
        form: {
          withdrawId: '',
          orgSNNo: '',
          withdrawType: 1,
          fillingLabel: 3
        },
        customerQuery: {
          fillingLabel: 2
        },
        customerForm: {
          csmName: '',
          csmCode: '',
          csmRgPhone: ''
        },
        userTableData: {
          data: [],
          total: 0,
          column: [
            {
              label: '选择',
              render: (h, { row }) => (
                <span onClick={(e) => e.preventDefault()}><el-checkbox v-model={row.isCheck} ></el-checkbox></span>
           )
            },
            {
              prop: 'csmName',
              minWidth: 160,
              label: '人员姓名'
            },
            {
              prop: 'csmCode',
              minWidth: 160,
              label: '人员编号'
            },
            {
              prop: 'csmRgPhone',
              minWidth: 160,
              label: '联系电话'
            },
            {
              prop: 'csmType',
              minWidth: 160,
              label: '用户类型',
              formatter: row => {
                return row.csmType && this.csmTypeMap[row.csmType]
              }
            }
          ]
        },
        fillingData: [],
        goodList: [],
        fillingInfo: {
          orgInfo: {},
          userInfo: {}
        },
        ownerList: [],
        currentSelect: {}
      }
    },
    computed: {
      ...mapGetters(['orgList', 'userInfo'])
    },
    async created() {
      await this.getDetaultTreeData()
    },
    methods: {
      getSummaries,
      open() {
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
          this.form.withdrawType = 1
          this.stepActive = 1
          this.form.fillingLabel = 1
          this.form.orgSNNo = this.userInfo.orgSNNo
          this.form.withdrawId = ''
          this.getOwnerList(this.userInfo.orgId)
        })
      },
      // 获取所属机构数据
      async getDetaultTreeData() {
        const data = this.orgList.map((item) => ({
          label: item.name,
          ...item
        }))
        this.treeData = getTreeData(data)
        this.form.orgSNNo = this.userInfo.orgSNNo
        this.getOwnerList(this.userInfo.orgId)
      },
      closed() {
      },
      reset() {
        this.fillingData = []
        this.fillingInfo = {
          orgInfo: {},
          userInfo: {}
        }
        this.form = {
          withdrawId: '',
          orgSNNo: '',
          withdrawType: '',
          fillingLabel: 1
        }
        this.customerQuery = {
          fillingLabel: 2
        }
        this.customerForm = {
          csmName: '',
          csmCode: '',
          csmRgPhone: ''
        }
        this.userTableData.data = []
        this.stepActive = 1
        this.form.orgSNNo = this.userInfo.orgSNNo
        this.getOwnerList(this.userInfo.orgId)
      },
      // 选择所属机构
      selectTreeChange(value) {
        const martchOrg = this.orgList.find((item) => item.orgSNNo === value.orgSNNo)
        this.form.withdrawId = ''
        this.getOwnerList(martchOrg.orgId)
      },
      // 查询处理人列表（新）
      async getOwnerList(orgId) {
        const res = await csDeliverUserList({ deliveryOrgId: orgId })
        this.ownerList = res.data
        if (this.ownerList.length) this.form.withdrawId = this.ownerList.userId
      },
      closeTree(v) {
        this.form.withdrawId = ''
        this.ownerList = []
      },
      async getGoodsData(orgId) {
        const res = await recycleEditWinNew({ orgId })
        const gtList = JSON.parse(res.data.gtList)
        const goodList = gtList.filter(item => item.gtFlag === 1)
        if (goodList && goodList[0]) {
          this.goodList = goodList[0].goodsList
          if (this.goodList.length > 0) {
            this.setDefaultData()
          }
        }
      },
      async setDefaultData() {
        this.goodList.forEach(item => {
          this.fillingData.push({
            goodsId: item.goodsId,
            goodsName: item.goodsName,
            specAlias: item.specAlias,
            specAliasCode: item.specAliasCode,
            weight: item.weight,
            goodsCount: 0,
            isEdit: true,
            gPrice: item.gPrice || 0,
            gPrefPrice: 0.00,
            totalPrice: 0.00
          })
        })
        // this.fillingData.push({
        //   goodsId: '',
        //   goodsName: '',
        //   specAlias: '',
        //   specAliasCode: '',
        //   weight: 0,
        //   goodsCount: 1,
        //   isEdit: true,
        //   gPrice: 0.00,
        //   gPrefPrice: 0.00,
        //   totalPrice: 0.00
        // })
        // this.goodsIdChange(this.goodList[0], 0)
      },
      async getCustormerInfo({ currentPage, pageSize }) {
        if (!(this.customerForm.csmName || this.customerForm.csmCode || this.customerForm.csmRgPhone)) {
          this.$message.error('查询条件不允许为空')
          return
        }
        var query = {
          currentPage: currentPage,
          pageSize: pageSize,
          ...this.customerForm,
          csmStatus: 9
        }
        const res = await fillingCsmList(query)
        if (res && res.data) {
          this.userTableData.data = res.data.rows.map((item) => ({
            ...item,
            isCheck: false
          }))
          this.rowSelect(this.userTableData.data[0])
          if (currentPage === 1) this.userTableData.total = res.data.total
        }
      },
      rowSelect(row) {
        const idx = this.userTableData.data.findIndex(item => item.csmId === row.csmId)
        this.userTableData.data.forEach((item, index) => {
          this.userTableData.data[index].isCheck = false
        })
        this.userTableData.data[idx].isCheck = true
        this.fillingInfo.userInfo = this.userTableData.data[idx]
      },
      withdrawTypeChange(e) {
        this.reset()
        this.form.withdrawType = e
      },
      // 监听回车键快捷查询
      onKeyupType() {
        clearTimeout(this.timer)
        this.timer = setTimeout(() => {
          this.onSubmit()
        }, 500)
      },
      onSubmit() {
        this.$refs.userLbTable.fetch({ currentPage: 1 })
      },
      usercancel() {
        this.reset()
        this.visible = false
        this.form.withdrawType = 1
      },
      userNext() {
        this.fillingData = []
        if (!this.form.withdrawType) {
          this.$message.warning('请选择提瓶充装人员！')
          return
        }
        if (this.form.withdrawType === 1) {
          if (!this.form.orgSNNo) {
            this.$message.warning('请选择责任机构！')
            return
          }
          if (!this.form.withdrawId) {
            this.$message.warning('请选择配送人员！')
            return
          }
          // if (!this.form.fillingLabel) {
          //   this.$message.warning('请选择单据标签！')
          //   return
          // }
          const org = this.orgList.find(item => item.orgSNNo === this.form.orgSNNo)
          const user = this.ownerList.find(item => item.userId === this.form.withdrawId)
          if (org) this.fillingInfo.orgInfo = org
          if (user) this.fillingInfo.userInfo = user
          this.fillingInfo.fillingLabelName = this.form.fillingLabel &&
            formatColumnMap(this.fillingLabelList, 'keyVal', this.form.fillingLabel, 'keyName')
          this.getGoodsData(this.fillingInfo.orgInfo.orgId)
        }
        if (this.form.withdrawType === 2) {
          // if (!this.customerQuery.fillingLabel) {
          //   this.$message.warning('请选择单据标签！')
          //   return
          // }
          if (!(this.fillingInfo.userInfo && this.fillingInfo.userInfo.csmId)) {
            this.$message.warning('请选择人员！')
            return
          }
          this.fillingInfo.fillingLabelName = this.customerQuery.fillingLabel &&
            formatColumnMap(this.fillingLabelList, 'keyVal', this.customerQuery.fillingLabel, 'keyName')
          this.getGoodsData(this.fillingInfo.userInfo.nearStation)
        }
        if (this.stepActive++ === 2) this.stepActive = 0
      },
      // 添加商品
      add() {
        this.fillingData.push({
          goodsId: '',
          goodsName: '',
          specAlias: '',
          specAliasCode: '',
          weight: 0,
          goodsCount: 1,
          gPrice: 0.00,
          gPrefPrice: 0.00,
          totalPrice: 0.00,
          isEdit: false
        })
      },
      // 编辑商品
      editClick(row, idx) {
        if (row.isEdit) {
          const i = this.fillingData.find(item => (item.goodsId === row.goodsId) && (!item.isEdit))
          if (i) {
            this.$message.warning('请勿重复添加商品')
            return
          }
          if ((row.gPrice * 1) * (row.goodsCount * 1) >= (row.gPrefPrice * 1)) {
            this.fillingData[idx].isEdit = false
          } else {
            this.$message.warning('优惠金额不得大于商品价格')
          }
        } else {
          this.fillingData[idx].isEdit = true
        }
      },
      // 删除
      delClick(row, idx) {
        this.fillingData.splice(idx, 1)
      },
      // 第二步取消
      cancel() {
        if (this.stepActive > 0) this.stepActive--
        this.fillingData = []
      },
      // 数量变化
      countPriceChange(row, idx) {
        if ((row.gPrice * 1) * (row.goodsCount * 1) >= (row.gPrefPrice * 1)) {
          this.fillingData[idx].totalPrice = ((row.gPrice * 1) * (row.goodsCount * 1) - (row.gPrefPrice * 1)).toFixed(2)
        } else {
          row.gPrefPrice = 0.00
          this.$message.warning('优惠金额不得大于商品价格')
        }
      },
      // 选择商品
      goodsIdChange(row, idx) {
        const good = this.goodList.find(item => item.goodsId === row.goodsId)
        this.fillingData[idx].goodsId = good.goodsId
        this.fillingData[idx].goodsName = good.goodsName
        this.fillingData[idx].specAliasCode = good.specAliasCode
        this.fillingData[idx].specAlias = good.specAlias
        this.fillingData[idx].weight = good.weight
        this.fillingData[idx].gPrice = good.gPrice
        this.fillingData[idx].totalPrice = (good.gPrice * 1).toFixed(2)
      },
      getParams() {
        const params = {
          DetailList: this.fillingData.filter((item) => {
            if (item.goodsCount) {
              return {
                goodsId: item.goodsId,
                goodsName: item.goodsName,
                goodsCount: item.goodsCount,
                specAliasCode: item.specAliasCode,
                specAlias: item.specAlias,
                weight: item.weight,
                gPrice: Number(item.gPrice.toFixed(2)),
                gPrefPrice: Number(item.gPrefPrice.toFixed(2)),
                totalPrice: Number(item.totalPrice)
              }
            }
          })
        }
        if (this.form.withdrawType === 1) {
          params.withdrawUser = this.fillingInfo.userInfo.userName
          params.withdrawCode = this.fillingInfo.userInfo.userCode
          params.withdrawId = this.fillingInfo.userInfo.userId
          params.withdrawType	 = this.form.withdrawType
          params.orgId = this.fillingInfo.orgInfo.orgId
          params.orgName = this.fillingInfo.orgInfo.orgName
          params.orgSNNo = this.form.orgSNNo
          params.fillingLabel = this.form.fillingLabel
        }
        if (this.form.withdrawType === 2) {
          params.withdrawUser = this.fillingInfo.userInfo.csmName
          params.withdrawCode = this.fillingInfo.userInfo.csmCode
          params.withdrawId = this.fillingInfo.userInfo.csmId
          params.withdrawType	 = this.form.withdrawType
          params.orgId = this.fillingInfo.userInfo.nearStation
          params.orgName = this.fillingInfo.userInfo.nearStationName
          params.orgSNNo = this.fillingInfo.userInfo.orgSNNo
          params.fillingLabel = this.customerQuery.fillingLabel
        }
        return params
      },
      // 保存
      async save() {
        if (!(this.fillingData && this.fillingData.length > 0)) {
          this.$message.warning('请添加商品')
          return
        }
        // const f = this.fillingData.some(item => !item.goodsId)
        // if (f) {
        //   this.$message.warning('请编辑商品信息')
        //   return
        // }
        // const noSave = this.fillingData.some(item => item.isEdit)
        // if (noSave) {
        //   this.$message.warning('存在未保存商品')
        //   return
        // }
        const params = await this.getParams()
        // console.log('params', params)
        const res = await fillingSave(params)
        if (res) {
          this.$message.success('保存成功')
          this.reset()
          this.resolve()
          this.visible = false
          this.form.withdrawType = 1
        }
      },
      async saveAndPrint() {
        if (!(this.fillingData && this.fillingData.length > 0)) {
          this.$message.warning('请添加商品')
          return
        }
        // const f = this.fillingData.some(item => !item.goodsId)
        // if (f) {
        //   this.$message.warning('请编辑商品信息')
        //   return
        // }
        // const noSave = this.fillingData.some(item => item.isEdit)
        // if (noSave) {
        //   this.$message.warning('存在未保存商品')
        //   return
        // }
        const params = await this.getParams()
        const res = await fillingSave(params)
        if (res && res.data) {
          this.$message.success('保存成功')
          this.groovePrint(res.data)
        }
      },
      async groovePrint(id) {
        const params = {
          fillingId: id
        }
        const res = await getfillingDetail(params)
        if (res && res.data) {
          this.print(res.data)
        }
      },
      print(row2) {
        const row = JSON.parse(JSON.stringify(row2))
        const cache = JSON.parse(localStorage.tp)
        if (!cache) {
          this.$message.warning('请先设置打印模板')
          return
        }
        const temp = cache['40']
        if (!temp) {
          this.$message.warning('请先设置打印模板')
          return
        }
        const r = {
          fillingTotalPrice: row.fillingTotalPrice,
          fillingCode: row.fillingCode,
          printDt: parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'),
          withdrawUser: row.withdrawUser,
          withdrawCode: row.withdrawCode,
          fillingCount: row.fillingCount,
          orgName: row.operateOrgName,
          fillingLabelName: row.fillingLabelName ? row.fillingLabelName : '',
          cardSurplus: row.cardSurplusName ? row.cardSurplusName : '',
          preferentialCount: row.preferentialCountName ? row.preferentialCountName : ''
        }
        const i = row.detailList.map((item) => ({
          goodsName: item.goodsName,
          specAlias: item.specAlias,
          weight: item.weight ? item.weight : '0',
          goodsCount: item.goodsCount
        }))

        let printcmd = {
          cmd: 2,
          title: `正在对充装单${r.fillingCode}进行打印`,
          elements: []
        }
        printcmd = { ...printcmd, ...temp }
        window.jCPrint.process(printcmd, temp, r, i)
        delete printcmd.els
        if (window.jCPrint.firePush(JSON.stringify(printcmd))) {
          this.$message.success('打印指令已发送')
          this.reset()
          this.resolve()
          this.visible = false
          this.form.withdrawType = 1
        } else {
          this.$message.error('打印未连接')
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
.userType {
  padding-left: 15px;
  margin: 22px 0;
}
.btn-b {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: right;
}
.item-title {
  margin: 10px  0;
  color: #01999F;
}
.grid-content {
  line-height: 30px;
}
.customerForm {
  /deep/ .el-form-item__content {
    input {
      width: 158px;
    }
  }
}
.fillingList {
  /deep/ .el-input-number--small {
    width: auto;
  }
}
.tree-select {
  width: 360px;
}
.userList {
  width: 360px;
}
.add {
  margin: 10px 0;
}
.del {
  color: red !important;
}
.tips {
  color: red;
  text-align: left;
}
</style>
